package com.deyuanyun.pic.ae.controller.dto;

import com.deyuanyun.pic.ae.domain.AEPipeline;
import com.deyuanyun.pic.ae.domain.DifficultyRepair;
import com.deyuanyun.pic.common.util.DateUtil;
import com.deyuanyun.pic.common.util.NumberUtil;
import com.deyuanyun.pic.common.util.StringUtils;

import java.math.BigDecimal;
import java.util.Date;

/**
 * E_6难以维修接近信息统计表
 */
public class DifficultyRepairEdit extends AEBaseEdit<DifficultyRepair>{

    // 管道编号
    private String pipeLineId;
    // 编号
    private String customNumber;
    //(填写)平行起点_附近测试桩pic_pipe_identification.ID_
    private String beginNagmInput;
    // (填写)平行起点_附近测试桩距离（相对值）
    private BigDecimal beginNagmMileageInput;
    // 起点X
    private BigDecimal beginX;
    // 起点Y
    private BigDecimal beginY;
    // 起点Z
    private BigDecimal beginZ;
    // (填写)平行段终点_附近测试桩pic_pipe_identification.ID_
    private String endNagmInput;
    // (填写)平行段终点_附近测试桩距离（相对值）
    private BigDecimal endNagmMileageInput;
    // 终点X
    private BigDecimal endX;
    // 终点Y
    private BigDecimal endY;
    // 终点Z
    private BigDecimal endZ;
    // 位置描述
    private String locationDescription;
    // 难以接近原因AE_DIFFICULTY_REPAIR_TYPE（沼泽、湖泊、水塘、山地、河流、建构筑物、其它）
    private String reason;
    // 联系人
    private String contact;
    // 联系方式
    private String telephone;

    public String getPipeLineId() {
        return pipeLineId;
    }

    public void setPipeLineId(String pipeLineId) {
        this.pipeLineId = pipeLineId;
    }

    public String getCustomNumber() {
        return customNumber;
    }

    public void setCustomNumber(String customNumber) {
        this.customNumber = customNumber;
    }

    public String getBeginNagmInput() {
        return beginNagmInput;
    }

    public void setBeginNagmInput(String beginNagmInput) {
        this.beginNagmInput = beginNagmInput;
    }

    public BigDecimal getBeginNagmMileageInput() {
        return beginNagmMileageInput;
    }

    public void setBeginNagmMileageInput(BigDecimal beginNagmMileageInput) {
        this.beginNagmMileageInput = beginNagmMileageInput;
    }

    public BigDecimal getBeginX() {
        return beginX;
    }

    public void setBeginX(BigDecimal beginX) {
        this.beginX = beginX;
    }

    public BigDecimal getBeginY() {
        return beginY;
    }

    public void setBeginY(BigDecimal beginY) {
        this.beginY = beginY;
    }

    public BigDecimal getBeginZ() {
        return beginZ;
    }

    public void setBeginZ(BigDecimal beginZ) {
        this.beginZ = beginZ;
    }

    public String getEndNagmInput() {
        return endNagmInput;
    }

    public void setEndNagmInput(String endNagmInput) {
        this.endNagmInput = endNagmInput;
    }

    public BigDecimal getEndNagmMileageInput() {
        return endNagmMileageInput;
    }

    public void setEndNagmMileageInput(BigDecimal endNagmMileageInput) {
        this.endNagmMileageInput = endNagmMileageInput;
    }

    public BigDecimal getEndX() {
        return endX;
    }

    public void setEndX(BigDecimal endX) {
        this.endX = endX;
    }

    public BigDecimal getEndY() {
        return endY;
    }

    public void setEndY(BigDecimal endY) {
        this.endY = endY;
    }

    public BigDecimal getEndZ() {
        return endZ;
    }

    public void setEndZ(BigDecimal endZ) {
        this.endZ = endZ;
    }

    public String getLocationDescription() {
        return locationDescription;
    }

    public void setLocationDescription(String locationDescription) {
        this.locationDescription = locationDescription;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    public String getContact() {
        return contact;
    }

    public void setContact(String contact) {
        this.contact = contact;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    @Override
    public void fromDomain(DifficultyRepair domain){

        // 管道编号
        this.pipeLineId = domain.getPipeLineId();
        // 编号
        this.customNumber = domain.getCustomNumber();
        //(填写)平行起点_附近测试桩pic_pipe_identification.ID_
        this.beginNagmInput = StringUtils.isNotNullEmpty(domain.getBeginNagmNumberInput()) ? domain.getBeginNagmNumberInput() : domain.getBeginNagmNumber();
        // (填写)平行起点_附近测试桩距离（相对值）
        this.beginNagmMileageInput = NumberUtil.toMeter(StringUtils.isNotNullEmpty(domain.getBeginNagmNumberInput()) ? domain.getBeginNagmMileageInput() : domain.getBeginNagmMileage());
        // 起点X
        this.beginX = domain.getBeginX();
        // 起点Y
        this.beginY = domain.getBeginY();
        // 起点Z
        this.beginZ = domain.getBeginZ();
        // (填写)平行段终点_附近测试桩pic_pipe_identification.ID_
        this.endNagmInput = StringUtils.isNotNullEmpty(domain.getEndNagmNumberInput()) ? domain.getEndNagmNumberInput() : domain.getEndNagmNumber();
        // (填写)平行段终点_附近测试桩距离（相对值）
        this.endNagmMileageInput = NumberUtil.toMeter(StringUtils.isNotNullEmpty(domain.getEndNagmNumberInput()) ? domain.getEndNagmMileageInput() : domain.getEndNagmMileage());
        // 终点X
        this.endX = domain.getEndX();
        // 终点Y
        this.endY = domain.getEndY();
        // 终点Z
        this.endZ = domain.getEndZ();
        // 位置描述
        this.locationDescription = domain.getLocationDescription();
        // 难以接近原因AE_DIFFICULTY_REPAIR_TYPE（沼泽、湖泊、水塘、山地、河流、建构筑物、其它）
        this.reason = domain.getReason();
        // 联系人
        this.contact = domain.getContact();
        // 联系方式
        this.telephone = domain.getTelephone();

        super.fromDomain(domain.getId(), domain.getRecorder(), domain.getRecordTime(), domain.getRemarks());
    }

    @Override
    public DifficultyRepair toDomain() {

        DifficultyRepair difficultyRepair = new DifficultyRepair();
        // 管道编号
        difficultyRepair.setPipeLineId(this.pipeLineId);
        // 编号
        difficultyRepair.setCustomNumber(this.customNumber);
        //(填写)平行起点_附近测试桩pic_pipe_identification.ID_
        difficultyRepair.setBeginNagmInput(this.beginNagmInput);
        // (填写)平行起点_附近测试桩距离（相对值）
        difficultyRepair.setBeginNagmMileageInput(NumberUtil.toMillimeter(this.beginNagmMileageInput));
        // 起点X
        difficultyRepair.setBeginX(this.beginX);
        // 起点Y
        difficultyRepair.setBeginY(this.beginY);;
        // 起点Z
        difficultyRepair.setBeginZ(this.beginZ);
        // (填写)平行段终点_附近测试桩pic_pipe_identification.ID_
        difficultyRepair.setEndNagmInput(this.endNagmInput);
        // (填写)平行段终点_附近测试桩距离（相对值）
        difficultyRepair.setEndNagmMileageInput(NumberUtil.toMillimeter(this.endNagmMileageInput));
        // 终点X
        difficultyRepair.setEndX(this.endX);
        // 终点Y
        difficultyRepair.setEndY(this.endY);
        // 终点Z
        difficultyRepair.setEndZ(this.endZ);
        // 位置描述
        difficultyRepair.setLocationDescription(this.locationDescription);
        // 难以接近原因AE_DIFFICULTY_REPAIR_TYPE（沼泽、湖泊、水塘、山地、河流、建构筑物、其它）
        difficultyRepair.setReason(this.reason);
        // 联系人
        difficultyRepair.setContact(this.contact);
        // 联系方式
        difficultyRepair.setTelephone(this.telephone);

        // id
        difficultyRepair.setId(this.getId());
        // 记录人
        difficultyRepair.setRecorder(this.getRecorder());
        // 记录时间
        Date recordTimeTemp = null;
        try {
            recordTimeTemp = DateUtil.allStr2Date(this.getRecordTime());
        } catch (Exception e) {
            e.printStackTrace();
        }
        difficultyRepair.setRecordTime(recordTimeTemp);
        // 备注
        difficultyRepair.setRemarks(this.getRemarks());

        return difficultyRepair;
    }
}